<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <style>
        body {
            text-align: center;
        }
        
        input {
            font: 12px;
            cursor: pointer;
            padding: 0 10px;
        }
    </style>

</head>

<body>
    <input type="button" value="0" />
</body>
<script type="text/javascript">
    var fang = document.getElementsByTagName("input")[0];
    var i = 0;

    fang.onclick = function() {

        fang.value = ++i;
        alert(i)
    }
</script>

</html>